<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <span>
          <b class="u-f-16">收益列表</b>
        </span>

        <div class="u-right u-5mt">
          <router-link
            :to="{ name: 'agencyEarningsAddBtn',params:{id:queryForm.agency_id}}"
            v-if="hasPerm('agencyEarningsAddBtn')"
          >
            <el-button type="danger" size="small" icon="el-icon-plus" round
              >添加收益</el-button
            >
          </router-link>
          <el-button size="small" icon="el-icon-back" @click="$router.go(-1)"
            >返回</el-button
          >
        </div>
      </div>

      <el-table :data="tableData" class="u-mt-10" v-viewer>
        <el-table-column label="id" prop="id" width="100"></el-table-column>
        <el-table-column label="收益类型">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.type == 1" type="info">代理商佣金</el-tag>
            <el-tag v-if="scope.row.type == 2" type="warning"
              >代理商利润</el-tag
            >
            <el-tag v-if="scope.row.type == 3" type="danger">代理商提现</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="变动前金额" prop="last_price"></el-table-column>
        <el-table-column label="变动金额" prop="price"></el-table-column>
        <el-table-column label="改变情况">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.change == 'add'" type="info">获得</el-tag>
            <el-tag v-if="scope.row.change == 'pay'" type="warning"
              >支付</el-tag
            >
            <el-tag v-if="scope.row.change == 'extract'" type="danger"
              >提现</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column label="状态">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.check == 0" type="info">已审核</el-tag>
            <el-tag v-if="scope.row.check == 1" type="warning">待审核</el-tag>
            <el-tag v-if="scope.row.check == 2" type="danger">审核失败</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="审核时间" prop="check_time"></el-table-column>
        <el-table-column label="创建时间" prop="create_date"></el-table-column>
      </el-table>
      <div class="u-mt-20 u-text-center">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="limit"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import commonPage from "@/mixins/common-page";
export default {
  mixins: [commonPage],
  data() {
    return {
      apiName: "agency",
      apiPage: "earningsPage", //方法
      queryForm: {
        agency_id: "",
      },
    };
  },
  methods: {},
  created() {
    this.queryForm.agency_id = this.$route.params.id;
    // window.console.log();
  },
};
</script>
